#ifndef XMLCONFIG_H
#define XMLCONFIG_H

#include <QtXml/QtXml>
#include <QStack>

#include "appconfig.h"

class ConfigHandler : public QXmlDefaultHandler {
public:
    ConfigHandler(AppConfig& conf);
    virtual ~ConfigHandler();

    void loadFromFile(const QString& path = "config.xml");

    virtual bool startDocument();
    virtual bool endDocument();
    virtual bool startElement(const QString &namespaceURI, const QString &localName,
                              const QString &qName, const QXmlAttributes &atts);
    virtual bool endElement(const QString &namespaceURI, const QString &localName,
                            const QString &qName);
    virtual bool characters(const QString &ch);

    virtual bool fatalError(const QXmlParseException& exc);

private:
    AppConfig& config;
    QString currentTag;
    QString filePath;

    QStack<QString> tags;

    void saveToFile();
};

/* ************************************************************************************ */

class ConfigTags {
public:
    static const QString CONFIG;
    static const QString WIN_WIDTH;
    static const QString WIN_HEIGHT;
    static const QString LAST_USED_SCHEDULE;

    static const QString SCHEDULE_DATE_FORMAT;
};

#endif // XMLCONFIG_H
